﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using CardLogistics.Web.Components;

namespace CardLogistics.Web.MainPage.SystemMgr.SysUser
{
    public partial class ListInfo : BasePage
    {
        private static readonly CardLogistics.DAL.Sys.Sys_SysUserInfoData DALUser = new DAL.Sys.Sys_SysUserInfoData();
        protected void Page_Load(object sender, EventArgs e)
        {
            wuc_toolbar.DeleteEvent += new EventHandler(DeleteUC);

            if (!IsPostBack)
            {
                BindRpt();
            }
        }

        #region 绑定数据
        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="pageIndex">当前页页码</param>
        private void BindRpt()
        {
            int recordCount = 0;
            int pageCount = 0;
            DataTable dt = CardLogistics.DAL.CommonData.QuickPage_Oracle("V_sys_sysuserinfo", "ID", " issys desc,CREATEDATE ", WebPageSize, WebPageIndex, " ISDELETED=0 ", "*", out pageCount, out recordCount);
            SetNetPagerHtml(AspNetPager1, dt, rptList, recordCount);
        }
        #endregion

        private void DeleteUC(object sender, EventArgs e)
        {
            string delId = hdf_Id.Value;

            string resStr = DALUser.Delete(delId);
            if (resStr.Split(',')[0] == "ok")
            {
                BindRpt();
            }
            else if (resStr.Split(',')[1]=="-1")
            {
                ShowMessageBox("该用户为管理员用户不可删除!");
            }
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            WebPageIndex = AspNetPager1.CurrentPageIndex;
            BindRpt();
        }
    }
}